package com.httpClient.chapter3;

import com.httpClient.chapter1.ParamHttpClient;
import com.httpClient.chapter2.config.OAConfig;
import com.httpClient.util.ResponseUtil;
import com.sky.JULLog.MyJulLogger;
import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.junit.Test;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Logger;

/**
 * date : 8/20/2025
 *
 * @author : wushikai
 */
public class ERR414 {


    private static Logger log = MyJulLogger.getLogger(ERR414.class);


    @Test
    public void doRequest( ) {


        CloseableHttpClient httpClient = HttpClients.createDefault();
        RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(-1)
                .setConnectTimeout(-1)
                .build();

        char[] cs = new char[8192*150];
        for(int i = 0; i < cs.length; i++) {
            cs[i] = 'A';
        }

        String s = new String(cs);
        HttpGet httpGet = new HttpGet();
        httpGet.setConfig(requestConfig);
        CloseableHttpResponse response = null;
        try {
            URI uri = new URI(OAConfig.SCHEMA, "", OAConfig.HOST, OAConfig.PORT, "/errFor414", "content="+s , null);
            httpGet.setURI(uri);
            response = httpClient.execute(httpGet);
            ResponseUtil.handleResponse(response);
            response.close();
        } catch (IOException | URISyntaxException e) {
            e.printStackTrace();
        } finally {

        }

    }


}
